package ExceptionDemo;

class UserNameException extends Exception {
    public UserNameException(String message) {
        super(message);
    }
}
class PasswordException extends Exception {
    public PasswordException(String message) {
        super(message);
    }
}
public class Login{
    private String userName = "curies";
    private String password = "666666";
    public void loginInfo(String userName, String password)
            throws UserNameException,PasswordException{
        if (!this.userName.equals(userName)) {
            throw new UserNameException("用户名错误！");
        }
        if (!this.password.equals(password)) {
            throw new PasswordException("密码错误！");
        }
        System.out.println("登陆成功");
    }
    public static void main(String[] args) {
        Login login = new Login();
        try {
            login.loginInfo("curies","13");
        } catch (UserNameException e) {
            e.printStackTrace();
        } catch (PasswordException e) {
            e.printStackTrace();
        }
    }
}

